package com.chandra.pos.common.entity;

/* @(#) UserEntity.java
 * Copyright 2013 - 2015 QatarAirways Group. All Rights Reserved.
 *
 * This Software is the proprietary information of QR Group
 * Use is subject to License terms.
 * Created by T4671 on 09/04/2015.
 */

import com.chandra.pos.common.dao.AbstractAuditableEntity;
import com.chandra.pos.common.dao.Status;
import com.chandra.pos.common.utils.JodaDateTimeJsonSerializer;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.annotations.Type;
import org.joda.time.DateTime;

import javax.persistence.*;

@MappedSuperclass
public class UserEntity extends AbstractAuditableEntity {

    @Column(name = "TITLE")
    @Enumerated(EnumType.STRING)
    private Title title;

    @Column(name = "FIRST_NAME")
    private String firstName;

    @Column(name = "MIDDLE_NAME")
    private String middleName;

    @Column(name = "LAST_NAME")
    private String lastName;

    @Column(name = "NICK_NAME")
    private String nickName;

    @Column(name = "EMAIL")
    private String email;

    @Column(name = "MOBILE")
    private String mobileNumber;

    @Column(name = "PHONE")
    private String phoneNumber;

    @Column(name = "NOTE")
    private String note;


    @Column(name = "ACCOUNT_NUMBER")
    private String accountNumber;

    @Column(name = "BALANCE_AMOUNT")
    private Double balanceAmount =0d;

    @Column(name = "BALANCE_UPDATED_DATE")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    @JsonSerialize(using = JodaDateTimeJsonSerializer.class)
    private DateTime balanceUpdatedDate;

    @Embedded
    private Address address;

    @Column(name = "STATUS")
    @Enumerated(EnumType.STRING)
    private Status status;


    public Double getBalanceAmount() {
        return balanceAmount;
    }

    @PrePersist
    public void prePersist() {
        if(balanceAmount == null) //We set default value in case if the value is not set yet.
            balanceAmount = 0d;
    }

    public void setBalanceAmount(Double balanceAmount) {
        this.balanceAmount = balanceAmount;
    }

    public DateTime getBalanceUpdatedDate() {
        return balanceUpdatedDate;
    }

    public void setBalanceUpdatedDate(DateTime balanceUpdatedDate) {
        this.balanceUpdatedDate = balanceUpdatedDate;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getAccountNumber() {
        return accountNumber;
    }

    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getMobileNumber() {
        return mobileNumber;
    }

    public void setMobileNumber(String mobileNumber) {
        this.mobileNumber = mobileNumber;
    }

    public Title getTitle() {
        return title;
    }

    public void setTitle(Title title) {
        this.title = title;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(final Address address) {
        this.address = address;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public String getMiddleName() {
        return middleName;
    }

    public void setMiddleName(String middleName) {
        this.middleName = middleName;
    }
}
